//
//  HealthInfoViewModel.swift
//  Health_Infomation
//
//  Created by 林帆 on 2017/10/21.
//  Copyright © 2017年 林帆. All rights reserved.
//

import Foundation
import Alamofire
import SwiftyJSON

class HealthInfoViewModel {
    lazy var ModelList = [HealthInfoModel]()

    func loadHealthInfo(idUsr : String) {
        Alamofire.request("http://111.200.225.242:18086/hinfo/view/usract/findAllcol?idUsr=\(idUsr)", method: .post, parameters: nil, encoding:  JSONEncoding.default, headers: nil).responseJSON { (response) in
            if (response.error == nil){
//                print(response.result.value)
//                print("请求成功");
//                let json = JSON(data: <#T##Data#>)
                let json = JSON(response.result.value ?? [])
                let model = HealthInfoModel(jsonData: json)
       
//                if let number = json[0]["phones"][0]["number"].string {
//                    // 找到电话号码
//                    print("第一个联系人的第一个电话号码：",number)
//                }
//                let data = response.result.value as! [String : AnyObject]
//                let MainDataDic = data["data"] as! [String : AnyObject]
//                let defaultDataArray =  MainDataDic["col_default"] as! [AnyObject];
//                self._DataArray?.removeAll()
//                for dic in defaultDataArray {
//                    let helModel = HealthInfoModel()
//                    //helModel.setValuesForKeys(dic as! [String : Any])
//                    self._DataArray?.append(helModel)
//                }
//                self.LoadMenuData()
            }else{
                print("请求失败");
            }
            
        }

    }
}
